import httpUtil from "../utils/httpUtil";
import zfbUrlUtil from "../utils/zfbUrlUtil";
import paramApi from "./paramApi";

// 省心云生活支付宝小程序 2021004123656452
// 省心停车支付宝小程序 2021004115620105
const skipZfbMiniAppid = '2021004115620105';

const setPagePath = (pagePath) => {
	uni.setStorageSync('pagePath', pagePath)
}

const getPagePath = () => {
	return uni.getStorageSync('pagePath')
}

const setAppid = (appid) => {
	uni.setStorageSync('appid', appid)
}

const getAppid = () => {
	let appid = uni.getStorageSync('appid')
	if (appid) {
		return appid
	}
	return skipZfbMiniAppid
}

const getZfbMiniUrl = () => {
	let alipayUrl = 'alipays://platformapi/startApp?appId=2021004129621025'+ '&page=pages/youku_newtcqv2/youku_newtcqv2'
	let query = "a=" + httpUtil.getA()
	if (paramApi.getParam()) {
		query += '&param=' + paramApi.getParam()
	}

	alipayUrl += '&query=' + encodeURIComponent(query)
	console.log('getZfbMiniUrl', alipayUrl)
	return zfbUrlUtil.wrapUrl(alipayUrl)
}
	

export default {
	skipZfbMiniAppid,
	getZfbMiniUrl,
	setPagePath,
	getPagePath,
	setAppid,
	getAppid,
}